﻿using RBAC.MaHaiBo.Entity;
using RBAC.MaHaiBo.Entity.Traceability;
using RBAC.MaHaiBo.Repository.Interface;
using RBAC.MaHaiBo.Repository.Interface.TraceabilityInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace RBAC.MaHaiBo.Repository.Impl.TraceabilityImpl
{
    /// <summary>
    /// 商品仓储
    /// </summary>
    public class CommodityRepository:BaseRepository<Commodity>, ICommodityRepository
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="context">上下文</param>
        public CommodityRepository(EFDbContext context): base(context) { }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>返回数据信息</returns>
        public async Task<Commodity> GetModelAsync(int id)
        {
            try
            {
                return await base.GetModelAsync(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 显示全部数据信息
        /// </summary>
        /// <returns>返回数据信息集合</returns>
        public async Task<List<Commodity>> GetAllAsync()
        {
            try
            {
                return await base.GetAllAsync();
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 根据条件查询多条数据信息
        /// </summary>
        /// <param name="expre">查询条件</param>
        /// <returns>返回数据信息集合</returns>
        public async Task<List<Commodity>> GetAsync(Expression<Func<Commodity, bool>> expre)
        {
            try
            {
                return await base.GetAsync(expre);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 添加数据信息
        /// </summary>
        /// <param name="expre">要添加的数据信息</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> AddAsync(Commodity expre)
        {
            try
            {
                return await base.AddAsync(expre);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改数据信息（逻辑删除）
        /// </summary>
        /// <param name="expre">修改后的数据信息</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> UpdateAsync(Commodity expre)
        {
            try
            {
                return await base.UpdateAsync(expre);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 批量修改相同数据信息（批量逻辑删除）
        /// </summary>
        /// <param name="values">要修改的数据编号集合</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> ByUpdateAsync(List<Commodity> values)
        {
            try
            {
                return await base.ByUpdateAsync(values);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 真删除
        /// </summary>
        /// <param name="expre">要删除的数据信息</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> DeleteAsync(Commodity expre)
        {
            try
            {
                return await base.DeleteAsync(expre);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
